package leetcode.tree;

import leetcode.tree.common.TreeNode;
import leetcode.tree.common.TreeUtils;

/**
 * Definition for a binary tree node.
 * public class TreeNode {
 * int val;
 * TreeNode left;
 * TreeNode right;
 * TreeNode() {}
 * TreeNode(int val) { this.val = val; }
 * TreeNode(int val, TreeNode left, TreeNode right) {
 * this.val = val;
 * this.left = left;
 * this.right = right;
 * }
 * }
 */
class Solution538 {
    public TreeNode convertBST(TreeNode root) {
        return TreeUtils.convertBST(root);
    }
}

public class leetcode538 {
    public static void main(String[] args) {
        Solution538 solution538 = new Solution538();
        Integer[] nums = {4, 1, 6, 0, 2, 5, 7, null, null, null, 3, null, null, null, 8};
        Integer[] nums1 = {0, null, 1};
        Integer[] nums2 = {1, 0, 2};
        Integer[] nums3 = {3, 2, 4, 1};
        test538(solution538, nums);
        test538(solution538, nums1);
        test538(solution538, nums2);
        test538(solution538, nums3);
    }

    private static void test538(Solution538 solution538, Integer[] nums) {
        TreeNode root = solution538.convertBST(TreeUtils.generateLeetcodeTree(nums));
        System.out.println(TreeUtils.getLeetcodeTreeVals(root));
    }
}
